package com.example.trafficexam2;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;

/**
 * Created by Administrator on 2018/11/26/026.
 */

public class RegularBusInfoActivity extends Activity {

    private Button nextBtn;
    private EditText username;
    private EditText userphone;
    private Spinner busloca;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.regular_bus_info_activity);
        initView();
        initdata();
    }

    private void initView(){
        nextBtn = findViewById(R.id.regular_next);
        username = findViewById(R.id.usernameEd);
        userphone = findViewById(R.id.user_phoneEd);
        busloca = findViewById(R.id.buslocaSp);
    }

    private void initdata(){
        nextBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SharedPreferences sharedPreferences = getSharedPreferences("userinfo", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = sharedPreferences.edit();
                editor.putString("username",username.getText().toString());
                editor.putString("userphone",userphone.getText().toString());
                editor.putString("busloca",busloca.getSelectedItem().toString());
                editor.commit();
                Intent intent = new Intent(RegularBusInfoActivity.this,RegularBusConfimInfoActivity.class);
                startActivity(intent);
            }
        });
    }
}
